/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */

package com.sys.midware.MQ.rocketMQ;

import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;

/**
 * <b>ClassName:</b> ProducerTest.java <br/>
 * <b>Description:</b> TODO <br/>
 * <b>Date:</b> 2015年10月19日 上午11:16:00<br/>
 * 
 * @author mobing
 * @version
 */
public class ProducerTest1 {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("QuickStartProducer");
        producer.setNamesrvAddr("10.0.0.33:9876");
        producer.setInstanceName("QuickStartProducer");
        producer.setVipChannelEnabled(false);
        producer.start();
        for (int i = 0; i < 1000; i++) {
            try {
                Message msg = new Message("QuickStart", // topic
                        "TagA", // tag
                        ("Hello RocketMQ ,QuickStart" + i).getBytes()// body
                );
                SendResult sendResult = producer.send(msg);
                System.out.println(sendResult);
            } catch (Exception e) {
                e.printStackTrace();
                Thread.sleep(1000);
            }
        }
        producer.shutdown();
    }
}
